﻿namespace FSpec.Runner.Model

open FSpec.Runner
open System
open Gallio.Model 
open Gallio.Common.Reflection 
open System.Linq

[<AllowNullLiteral>]
type Specification(name:String, codeElement) as this = 
    inherit Tree.Test(
        (
            if name.StartsWith "it" then 
                Let + name 
            else 
                name
        ), 
        codeElement
    )
    do
        let declaringType = (ReflectionUtils.GetType codeElement)
        let asm = ReflectionUtils.GetAssembly codeElement
        if asm <> null then ModelUtils.PopulateMetadataFromAssembly(asm, this.Metadata)

        codeElement |> insertXmlDocsInto this
        this.IsTestCase <- true
        this.Kind <- "Specification"
        this.Metadata.Add(MetadataKeys.Category, getCategoriesFor codeElement)
 
       

